﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using QuanLyChoVay.Bussiness;
using QuanLyChoVay.Entity;
using QuanLyChoVay.Database;

namespace QuanLyChoVay
{
    public partial class KhachHangDangKy : Form
    {
        KhachHangBuss khbus;
        KhachHang kh;
        public KhachHangDangKy()
        {
            InitializeComponent();
        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {

        }

        private void btndangky_Click(object sender, EventArgs e)
        {
            kh = new KhachHang();
            kh.Tendn = txttendangnhap.Text;
            kh.Matkhau = txtmatkhau.Text;
            kh.Hoten = txthoten.Text;
            kh.Email = txtemail.Text;
            kh.Diachi = txtdiachi.Text;
            kh.Ngaysinh = dateTimePicker1.Text;
            kh.Quequan = txtquequan.Text;
            kh.Sdt = txtsodienthoai.Text;
            kh.Tienluong =Convert.ToInt32(txttienluong.Text);
            kh.Tochuc = txttochuc.Text;

            khbus = new KhachHangBuss();
            try
            {
                khbus.insertKhachHang(kh);
                MessageBox.Show("insert than cong!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("xay ra loi khi insert");
                MessageBox.Show(ex.ToString());
              
            }
        }

        private void btnhuybo_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có chắc chắn muốn hủy bỏ", "Xác nhận hủy bỏ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                this.Dispose();
            }
        }

        private void btnlamlai_Click(object sender, EventArgs e)
        {
            txttendangnhap.Text = "";
            txtmatkhau.Text = "";
            txthoten.Text = "";
            txtemail.Text = "";
            txtquequan.Text = "";

            txtdiachi.Text = "";
            txtsodienthoai.Text = "";
            txttienluong.Text = "";
            txttochuc.Text = "";
        }
    }
}
